27-Simple writing to a file.py


Sign up Free. Don't forget to check out our challenges, lessons, solve and learn series and more ...


Code Snippet

file1 = open("C:\\temp\\tester2.txt","w")
print (file1) # prints out details about the file
file1.write("Today is Monday\n") 
file1.write("Tomorrow is Tuesday")
file1.close()

#Example from: http://www.annedawson.net/Python3Programs.txt

                    

Try it yourself